package com.playball.lottery.frm.hemai;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;

import com.playball.lottery.R;
import com.playball.lottery.ApplicationData;
import com.playball.lottery.base.BaseActivity;
import com.playball.lottery.customview.ShowCustomDialog;
import com.playball.lottery.customview.ShowTipDialog;
import com.playball.lottery.frm.yhzx.LoginActivity;
import com.playball.lottery.nt.GetRequestParams;
import com.playball.lottery.util.AppUtils;
import com.playball.lottery.util.Constants;
import com.playball.lottery.util.ConvertJsonToList;
import com.playball.lottery.util.LevelUtil;
import com.playball.lottery.util.LotUtil;
import com.playball.lottery.util.SysApplication;
import com.playball.lottery.util.Utility;


/**
 * 合买详情
 * 
 * @author Administrator
 * 
 */
public class HeMaiDetailActivity extends BaseActivity {
	/** 上下文内容 */
	private Context context = null;
	/** 金额输入框 */
	private EditText etOPMoney;
	/** 购买 */
	private Button btnBuy;
	private int buy_icon;
	// private ApplicationBall app;// 全局变量
	private int schemeID;
	private Map<String, Object> mData;
	private List<Map<String, Object>> rData = new ArrayList<Map<String, Object>>();
	// 发起人，彩种，期次，状态
	/** 彩种名称 */
	private TextView tvLotName;
	/** 发起人 */
	private TextView tvPeople;
	/** 战绩 */
	private ImageView ivLevel;
	/** 期次 */
	private TextView tvLaunchTime;
	/** 状态 */
	private TextView tvStatus;
	// 方案金额，提成佣金，发起认购额，参与人数，保底金额，方案进度，截止认购
	/** 方案金额 */
	private TextView tvAmount;
	/** 提成佣金 */
	private TextView tvCommission;
	/** 参与人数 */
	private TextView tvCanyu;
	/** 保底金额 */
	// private TextView tvBaodi;
	/** 方案进度 */
	private TextView tvProcess1;
	private TextView tvProcess2;
	/** 截止认购 */
	private TextView tvEndTime;
	/** 可认购金额 */
	private TextView tvKRGMoney;
	/** 是否预售期 */
	private TextView tvYsq;
	private SimpleAdapter adapter = null;
	private ListView lv;
	private TextView textPassType;
	private View layoutPassType;
	private View layoutHasDetail;
	private View layoutHasNoDetail;

	private View layoutListPar;
	// private View layoutListHeadPar;
	// private View layoutListHeadLine;
	// private View detail_view_title;
	private boolean isNumGame; // 是否为数字彩
	private boolean isJcBasketball;// 是否为竞彩篮球
	private boolean isSFC;// 是否为胜负彩
	/** 投注倍数 */
	private TextView tvMultiple;
	/** 无显示方案,未上传 */
	private TextView hemai_detail_tvNO;
	/** 输入金额 */
	private float fEnter;
	/** 剩余金额 */
	private float fLeft;
	// /** 全包按钮 */
	// private Button btnDQB;
	/** 全包 */
	// private CheckBox cbQuanBao;
	/** 全包 */
	private View buy_hemai_ll_guarantee_all;
	/** 是否为竞彩篮球大小分 */
	private boolean isJcBasketballDXF;
	/** 是否为竞彩篮球胜负 */
	private boolean isJcBasketballSF;
	/** 是否为竞彩篮球让分胜负 */
	private boolean isJcBasketballRFSF;
	/** 是否为竞彩篮球胜分差 */
	private boolean isJcBasketballSFC;
	/** 是否为竞彩篮球混合过关 */
	private boolean isJcBasketballHunHe;
	/** 彩种名称 */
	private String lottName;
	/** 竞彩足球，竞彩篮球,北单,玩法分类 */
	private String PlayTypeName;
	/** 是否是未上传,初始值false */
	private boolean isNotUpload;
	/** 是否是投注内容已经被保密,初始值false */
	private boolean isSecret;
	/** 是否无item,和BetType =2,3,4,5，需到网站查看方案详情 */
	private boolean isToWeb;
	/** 是否为竞彩足球玩法让球胜平负 */
	private boolean isJczqRQSPF;
	/** 是否为竞彩足球玩法 */
	private boolean isJcFootball;
	/** 是否为竞彩足球玩法混合过关 */
	private boolean isJczqHunHe;
	/** 是否为竞彩足球玩法半全场 */
	private boolean isJczqBQC;
	/** 是否为竞彩足球玩法比分 */
	private boolean isJczqBF;
	/** 是否为竞彩足球玩法胜平负 */
	private boolean isJczqSPF;
	/** 玩法 */
	private TextView textPlayType;
	/** 是否中奖 */
	boolean isMyWinMoney;
	/** 是否为北京单场玩法半全场 */
	private boolean isBdBQC;
	/** 是否为北京单场玩法胜平负 */
	private boolean isBdSPF;
	/** 是否为北京单场玩法上下单双 */
	private boolean isBdSXDS;
	/** 是否为北京单场玩法比分 */
	private boolean isBdBF;
	/** 是否为北京单场玩法 */
	private boolean isBd;
	Button hemai_detail_back;
	/** 彩种图标 */
	private ImageView lottImg;

	// 各彩种标题栏
	private View view_list_title_num;
	private View view_list_title_sfc;
	private View view_list_title_jclqrfsf;
	private View view_list_title_jclqhunhe;
	private View view_list_title_jclq;
	private View view_list_title_jczqhunhe;
	private View view_list_title_jc;
	private View yhzx_detail_multiple_par;
	private LinearLayout llBelowInfo;
	private LinearLayout look_case_lin;
	private ImageView ivArrow;
	private Button sub_issue;
	private Button add_issue;
	private ScrollView hemai_scr;
	private TextView tv_Lot;
	private TextView tvSecState;
	private TextView description_tex;
	private LinearLayout llFoot;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.context = this;
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.new_hemai_detail);
		SysApplication.getInstance().addActivity(this);
		// app = (ApplicationBall) getApplication();

		schemeID = Integer.parseInt(getBundleStr("SchemeID"));

		titleBar();
		initView();
		initListener();
		// 启动获取详情数据线程
		startDetailThread();
	}

	public final String getBundleStr(final String key) {
		Intent intent = getIntent();
		Bundle bundle = intent.getExtras();
		if (bundle == null) {
			return "";
		} else {
			return bundle.getString(key);
		}
	}

	public void onResume() {
		super.onResume();
		
	}

	public void onPause() {
		super.onPause();
		
	}

	/**
	 * 初始化视图
	 */
	public void initView() {
		etOPMoney = (EditText) findViewById(R.id.hemai_detail_etOPMoney);
		btnBuy = (Button) findViewById(R.id.hemai_detail_btnBuy);
		// cbQuanBao = (CheckBox) findViewById(R.id.cbQuanBao);
		llFoot = (LinearLayout) findViewById(R.id.llFoot);
		buy_hemai_ll_guarantee_all = findViewById(R.id.buy_hemai_ll_guarantee_all);
		buy_hemai_ll_guarantee_all.setSelected(false);

		lottImg = (ImageView) findViewById(R.id.buy_main_lott_ico);
		tvLotName = (TextView) findViewById(R.id.tvLotName);
		tvPeople = (TextView) findViewById(R.id.tvPeople);
		ivLevel = (ImageView) findViewById(R.id.ivLevel);
		tvYsq = (TextView) findViewById(R.id.tvYsq);
		tvLaunchTime = (TextView) findViewById(R.id.tvLaunchTime);
		tvStatus = (TextView) findViewById(R.id.tvStatus);
		tvAmount = (TextView) findViewById(R.id.tvAmount);
		tvCommission = (TextView) findViewById(R.id.tvCommission);
		tvCanyu = (TextView) findViewById(R.id.tvCanyu);
		// tvBaodi = (TextView) findViewById(R.id.tvBaodi);
		tvProcess1 = (TextView) findViewById(R.id.tvProcess1);
		tvProcess2 = (TextView) findViewById(R.id.tvProcess2);
		tvEndTime = (TextView) findViewById(R.id.tvEndTime);
		tvKRGMoney = (TextView) findViewById(R.id.hemai_detail_tvKRGMoney);
		lv = (ListView) findViewById(R.id.lv);

		textPassType = (TextView) findViewById(R.id.yhzx_detail_passtype);
		textPlayType = (TextView) findViewById(R.id.yhzx_detail_playtype);
		// 有数据
		layoutPassType = findViewById(R.id.yhzx_detail_layout_passtype);
		layoutHasDetail = findViewById(R.id.yhzx_detail_layout01);

		// 未上传或无详情内容
		layoutHasNoDetail = findViewById(R.id.yhzx_detail_layout02);
		hemai_detail_tvNO = (TextView) findViewById(R.id.hemai_detail_tvNO);

		// 胜负彩、任选九相关
		layoutListPar = findViewById(R.id.yhzx_plan_detail_list_par);
		// layoutListHeadLine =
		// findViewById(R.id.yhzx_plan_detail_list_head_line);

		view_list_title_sfc = findViewById(R.id.view_list_title_sfc);
		view_list_title_num = findViewById(R.id.view_list_title_num);
		view_list_title_jclqrfsf = findViewById(R.id.view_list_title_jclqrfsf);
		view_list_title_jclqhunhe = findViewById(R.id.view_list_title_jclqhunhe);
		view_list_title_jclq = findViewById(R.id.view_list_title_jclq);
		view_list_title_jczqhunhe = findViewById(R.id.view_list_title_jczqhunhe);
		view_list_title_jc = findViewById(R.id.view_list_title_jc);

		tvMultiple = (TextView) findViewById(R.id.yhzx_detail_multiple);
		hemai_detail_back = (Button) findViewById(R.id.hemai_detail_back);
		yhzx_detail_multiple_par = findViewById(R.id.yhzx_detail_multiple_par);

		llBelowInfo = (LinearLayout) findViewById(R.id.llBelowInfo);
		look_case_lin = (LinearLayout) findViewById(R.id.look_case_lin);
		ivArrow = (ImageView) findViewById(R.id.ivArrow);
		sub_issue = (Button) findViewById(R.id.btn_intell_sub_issue);
		add_issue = (Button) findViewById(R.id.btn_intell_add_issue);
		hemai_scr = (ScrollView) findViewById(R.id.hemai_scr);
		tv_Lot = (TextView) findViewById(R.id.hemai_tv_Lot);
		tvSecState = (TextView) findViewById(R.id.tvSecState);
		description_tex = (TextView) findViewById(R.id.description_tex);
	}

	/**
	 * 初始化监听器
	 */
	public void initListener() {

		etOPMoney.addTextChangedListener(new TextWatcher() {
			private boolean isChanged = false;

			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {
				// TODO Auto-generated method stub
				if (isChanged) {
					return;
				}
				isChanged = true;

				float fMoney;
				int intBS;
				try {
					fMoney = Float.parseFloat(String.valueOf(mData.get("Money")).replace(",", ""));
					intBS = Integer.parseInt(String.valueOf(mData.get("BS")));
				} catch (Exception e) {
					fMoney = 0;
					intBS = 0;
				}

				float op;

				if (s.toString().equals("")) {
					op = 0;
				} else {
					op = Float.parseFloat(s.toString());
				}

				String str2 = s.toString().trim().replaceFirst("^0*", "");

				if (op > fMoney - intBS) {
					op = fMoney - intBS;
					etOPMoney.setText((int) op + "");
					etOPMoney.selectAll();
				} else if (op < 1) {
					op = 1;
					etOPMoney.setText((int) op + "");
					etOPMoney.selectAll();
				} else {
					etOPMoney.setText(str2);
					etOPMoney.setSelection(etOPMoney.length());
				}

				if (op == fMoney - intBS)
					buy_hemai_ll_guarantee_all.setSelected(true);
				else
					buy_hemai_ll_guarantee_all.setSelected(false);

				isChanged = false;
				// etOPMoney.invalidate();
			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count, int after) {
				// TODO Auto-generated method stub

			}

			@Override
			public void afterTextChanged(Editable s) {
				// TODO Auto-generated method stub

			}
		});
		etOPMoney.setSelection(etOPMoney.length());

		buy_hemai_ll_guarantee_all.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				v.setSelected(!v.isSelected());
				if (v.isSelected()) {
					float fMoney;
					int intBS;
					try {
						fMoney = Float.parseFloat(String.valueOf(mData.get("Money")).replace(",", ""));
						intBS = Integer.parseInt(String.valueOf(mData.get("BS")));
					} catch (Exception e) {
						fMoney = 0;
						intBS = 0;
					}
					// 可认购金额=方案金额-发起认购
					String strKRGMoney = String.valueOf((int) fMoney - intBS);
					etOPMoney.setText(strKRGMoney);
					etOPMoney.selectAll();
				} else {
					etOPMoney.setText("1");
					etOPMoney.selectAll();
				}
			}
		});

		btnBuy.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if ("".equals(String.valueOf(etOPMoney.getText().toString()))) {
					fEnter = 0;
				} else {
					fEnter = Float.parseFloat(String.valueOf(etOPMoney.getText().toString()));
				}
				if (checkUserLogin()) {
					// 判断输入是否合法
					// if (0 == fEnter) {
					// Toast.LENGTH_SHORT).show();
					// }
					if (Math.abs(fEnter) < 0.0000001) { // 输入不能为0
						Toast.makeText(HeMaiDetailActivity.this, R.string.input_amount_can_not_be_empty,
								Toast.LENGTH_SHORT).show();
					}
					// else if (intEnter >
					// (Integer.parseInt(String.valueOf(mData.get("Money"))) -
					// Integer.parseInt(String.valueOf(mData.get("BS"))))) {
					// Toast.LENGTH_SHORT).show();
					// }
					else {
						// 弹出购买提示框
						ShowCustomDialog/* AlertDialog.Builder */dialog = new ShowCustomDialog.Builder(
								HeMaiDetailActivity.this).setTitle("购买提示").setMessage("是否确认购买？")

						.setPositiveButton("取消", new DialogInterface.OnClickListener() {
							@Override
							public void onClick(DialogInterface dialog, int which) {
								dialog.dismiss();
							}
						}).setNegativeButton("确定", new DialogInterface.OnClickListener() {
							@Override
							public void onClick(DialogInterface dialog, int which) {
								startHBuyThread();
								dialog.dismiss();
							}
						}).createCustomDialog();
						dialog.setCanceledOnTouchOutside(false);
						dialog.setCancelable(true);// 设置back键是否可以取消
						dialog.show();

					}
				} else {
					Intent intent = new Intent(context, LoginActivity.class);
					context.startActivity(intent);
				}
			}
		});

		hemai_detail_back.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				HeMaiDetailActivity.this.finish();
			}
		});

		look_case_lin.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (llBelowInfo.getVisibility() == View.GONE) {
					llBelowInfo.setVisibility(View.VISIBLE);
					ivArrow.setBackgroundResource(R.drawable.hemai_up);
					handler.post(new Runnable() {
						@Override
						public void run() {
							hemai_scr.fullScroll(ScrollView.FOCUS_DOWN);
						}
					});
				} else {
					llBelowInfo.setVisibility(View.GONE);
					ivArrow.setBackgroundResource(R.drawable.hemai_down);
				}

			}
		});

		sub_issue.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				etOPMoney.setText((Integer.valueOf(etOPMoney.getText().toString()) - 1) + "");
			}
		});

		add_issue.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				etOPMoney.setText((Integer.valueOf(etOPMoney.getText().toString()) + 1) + "");
			}
		});
	}

	/**
	 * 获取详情
	 */
	public void startDetailThread() {
		AsyncLoader task = new AsyncLoader();

		String[] dyn = new String[2];
		JSONObject params = new JSONObject();
		try {
			params.put("SchemeID", schemeID);
			params.put("DataSource", 1);// 数据来源 0老系统，1新系统
		} catch (JSONException ex) {
			// TODO Auto-generated catch block
			Log.e("error", ex.toString());
		}
		dyn[0] = params.toString();
		// 方案详情
		dyn[1] = "210";// 116
		task.execute(dyn);
	}

	/**
	 * 购买
	 */
	private void startHBuyThread() {
		AsyncLoader task = new AsyncLoader();
		String[] dyn = new String[2];
		JSONObject params = new JSONObject();

		try {
			// 设置请求所需参数
			params.put("BuyShare", fEnter);
			params.put("SchemeID", schemeID);
			params.put("DataSource", 1);// 数据来源 0老系统，1新系统
		} catch (JSONException ex) {
			// TODO Auto-generated catch block
			Log.e("error", ex.toString());
		}
		dyn[0] = params.toString();
		// 参与合买
		dyn[1] = "209";// 213
		// Log.e("startHBuyThread= ", dyn[1].toString() + " " +
		// dyn[0].toString());
		task.execute(dyn);
	}

	/**
	 * 异步发送接收处理网络数据
	 * 
	 * @author Administrator
	 * 
	 */
	class AsyncLoader extends AsyncTask<String, Integer, String> {// 继承AsyncTask

		String action;
		ShowTipDialog showdialog = new ShowTipDialog();

		// 1.准备运行
		protected void onPreExecute() {
			showdialog.showDialog(HeMaiDetailActivity.this);
		}

		// 2.正在后台运行
		@Override
		protected String doInBackground(String... paramsArr) {
			// 处理后台执行的任务，在后台线程执行
			String strResult = null;

			action = paramsArr[1];
			// 获取请求返回值
			String UserID = ApplicationData.getInstance().getUserID();
			strResult = GetRequestParams.getRequestUserIDResult(paramsArr[0], UserID, action, getApplicationContext());
			// strResult =
			// GetRequestParams.getRequestResult(paramsArr[0],action,
			// getApplicationContext());
			return strResult;
		}

		// 3.进度更新
		protected void onProgressUpdate(Integer... progress) {
		}

		// 4.完成后台任务
		protected void onPostExecute(String result) {
			if (result != null) {

				if (action.equals("210")) {
					// 获取详情
					getDetail(result);
					//Log.d("van", "-------" + result);
				}
				if (action.equals("209")) {
					// 购买
					HdetailBuy(result);
				}
				showdialog.closeDialog();
			} else {
				Toast.makeText(HeMaiDetailActivity.this, getString(R.string.problem_01), Toast.LENGTH_LONG).show();
			}
		}

		// 5.完成后操作
		protected void onCancelled() {
		}

	}

	/**
	 * 获取及显示详情
	 * 
	 * @param strResult
	 */
	public void getDetail(String strResult) {
		mData = getData(strResult);

		if (mData != null && !mData.equals("")) {
			String number = (String) mData.get("LotNumber");
			// Log.d("detail", "LotNumber number= "+number);
			if (number == null || number.equals("")) {
				layoutHasNoDetail.setVisibility(View.VISIBLE);
				layoutHasDetail.setVisibility(View.GONE);

				setTextView();
			} else {
				Boolean iscansee = (Boolean) mData.get("IsCanSee");
				// 如果可见
				if (iscansee) {
					if (!isNotUpload && !isToWeb) {
						// Log.d("showDetailContent", "可见的");
						layoutHasDetail.setVisibility(View.VISIBLE);
						layoutHasNoDetail.setVisibility(View.GONE);
					} else {
						layoutHasDetail.setVisibility(View.GONE);
						layoutHasNoDetail.setVisibility(View.VISIBLE);
					}
				} else {
					layoutHasDetail.setVisibility(View.GONE);
					layoutHasNoDetail.setVisibility(View.VISIBLE);
				}
				if (isNumGame) {

					setTextView();

					if (rData == null) {
						Log.i("getd", "rData=null");
					} else {
						// Log.i("getd", "rData= "+rData.toString());
						view_list_title_num.setVisibility(View.VISIBLE);

						adapter = new NumberPlanDetailAdapter(HeMaiDetailActivity.this, rData,
								R.layout.hemai_detail_numgamelist, new String[] { "PlayTypeName", "LotNum" },
								new int[] { R.id.yhzx_plan_detail_PlayTypeName, R.id.yhzx_plan_detail_winnum });
						lv.setAdapter(adapter);
						Utility.setListViewHeightBasedOnChildren(lv);
					}
				} else {
					setTextView();
					// 同投注记录
					if (isSFC) {
						view_list_title_sfc.setVisibility(View.VISIBLE);
						adapter = new SFCDetailAdapter(HeMaiDetailActivity.this, rData, R.layout.hemai_detail_sfc_list,
								new String[] { "NO", "Content", "HTeam", "VTeam", "Result", "Score" }, new int[] {
										R.id.yhzx_detail_list_mno, R.id.yhzx_detail_list_tzh,
										R.id.yhzx_detail_list_hteam, R.id.yhzx_detail_list_vteam,
										R.id.yhzx_detail_list_cg, R.id.yhzx_detail_list_score });
					} else {
						if (isJcBasketball) {
							// Log.d("isJcBasketball",
							// "isJcBasketball rData= "+rData.toString());
							List<Map<String, Object>> lqList = new ArrayList<Map<String, Object>>();
							lqList = modifymjclqData(rData);
							// Log.e("isJcBasketball",
							// "lqList----------------- ");
							if (lqList != null) {
								// Log.d("isJcBasketball",
								// "lqList= "+lqList.toString());
								if (isJcBasketballDXF) {
									view_list_title_jclqrfsf.setVisibility(View.VISIBLE);

									findViewById(R.id.yhzx_detail_list_tvysf).setVisibility(View.GONE);
									findViewById(R.id.yhzx_detail_list_rq).setVisibility(View.VISIBLE);

									// 大小分
									adapter = new jclqDXFPlanDetailAdapter(HeMaiDetailActivity.this, lqList,
											R.layout.hemai_detail_jclqrfsf_list, new String[] { "MNo", "Content",
													"HTeam", "VTeam", "Cg", "ysf", "Score", "ysftv" }, new int[] {
													R.id.yhzx_detail_list_mno, R.id.yhzx_detail_list_tzh,
													R.id.yhzx_detail_list_hteam, R.id.yhzx_detail_list_vteam,
													R.id.yhzx_detail_list_cg, R.id.yhzx_detail_list_rq,
													R.id.yhzx_detail_list_score, R.id.yhzx_detail_list_tvysf, });
								} else if (isJcBasketballRFSF) {
									view_list_title_jclqrfsf.setVisibility(View.VISIBLE);

									// 让分胜负
									adapter = new jclqRFSFPlanDetailAdapter(HeMaiDetailActivity.this, lqList,
											R.layout.hemai_detail_jclqrfsf_list, new String[] { "MNo", "Content",
													"HTeam", "VTeam", "Cg", "Rq", "Score" }, new int[] {
													R.id.yhzx_detail_list_mno, R.id.yhzx_detail_list_tzh,
													R.id.yhzx_detail_list_hteam, R.id.yhzx_detail_list_vteam,
													R.id.yhzx_detail_list_cg, R.id.yhzx_detail_list_rq,
													R.id.yhzx_detail_list_score });
								} else if (isJcBasketballHunHe) {
									view_list_title_jclqhunhe.setVisibility(View.VISIBLE);
									adapter = new jclqHunHePlanDetailAdapter(HeMaiDetailActivity.this, lqList,
											R.layout.hemai_detail_jclqhunhe_list, new String[] { "MNo", "Content",
													"HTeam", "VTeam", "Rf", "Score" }, new int[] {
													R.id.yhzx_detail_list_mno, R.id.yhzx_detail_list_tzh,
													R.id.yhzx_detail_list_hteam, R.id.yhzx_detail_list_vteam,
													R.id.yhzx_detail_list_rf, R.id.yhzx_detail_list_score });
								} else {
									view_list_title_jclq.setVisibility(View.VISIBLE);
									adapter = new jclqPlanDetailAdapter(HeMaiDetailActivity.this, lqList,
											R.layout.hemai_detail_jclq_list, new String[] { "MNo", "Content", "HTeam",
													"VTeam", "Cg", "Score" }, new int[] { R.id.yhzx_detail_list_mno,
													R.id.yhzx_detail_list_tzh, R.id.yhzx_detail_list_hteam,
													R.id.yhzx_detail_list_vteam, R.id.yhzx_detail_list_cg,
													R.id.yhzx_detail_list_score });
								}
							}
						} else {
							// Log.d("de", "rData= "+rData.toString());
							List<Map<String, Object>> zqList = new ArrayList<Map<String, Object>>();
							zqList = modifymZQData(rData);
							if (zqList != null) {
								if (isJczqHunHe) {
									view_list_title_jczqhunhe.setVisibility(View.VISIBLE);
									adapter = new jczqhhPlanDetailAdapter(HeMaiDetailActivity.this, zqList,
											R.layout.hemai_detail_jczqhunhe_list, new String[] { "MNo", "Content",
													"HTeam", "VTeam", "Score" }, new int[] { R.id.yhzx_detail_list_mno,
													R.id.yhzx_detail_list_tzh, R.id.yhzx_detail_list_hteam,
													R.id.yhzx_detail_list_vteam, R.id.yhzx_detail_list_score });
								} else {
									// adapter = new
									// jczqPlanDetailAdapter(HeMaiDetailActivity.this,
									// zqList, R.layout.hemai_detail_jc_list,
									// new String[] { "MNo", "Content", "HTeam",
									// "VTeam", "Cg", "Rq", "Score" }, new int[]
									// { R.id.yhzx_detail_list_mno,
									// R.id.yhzx_detail_list_tzh,
									// R.id.yhzx_detail_list_hteam,
									// R.id.yhzx_detail_list_vteam,
									// R.id.yhzx_detail_list_cg,
									// R.id.yhzx_detail_list_rq,
									// R.id.yhzx_detail_list_score });

									view_list_title_jc.setVisibility(View.VISIBLE);
									adapter = new jczqPlanDetailAdapter(HeMaiDetailActivity.this, zqList,
											R.layout.hemai_detail_jc_list, new String[] { "MNo", "Content", "HTeam",
													"VTeam", "Cg", "Score" }, new int[] { R.id.yhzx_detail_list_mno,
													R.id.yhzx_detail_list_tzh, R.id.yhzx_detail_list_hteam,
													R.id.yhzx_detail_list_vteam, R.id.yhzx_detail_list_cg,
													R.id.yhzx_detail_list_score });
								}
							}
						}

					}
					if (adapter != null) {
						lv.setAdapter(adapter);
						Utility.setListViewHeightBasedOnChildren(lv);
					}

				}
			}
		} else {
			Toast.makeText(HeMaiDetailActivity.this, R.string.solution_does_not_exist, Toast.LENGTH_LONG).show();
			btnBuy.setEnabled(false);
			// btnDQB.setEnabled(false);
			// cbQuanBao.setEnabled(false);
			buy_hemai_ll_guarantee_all.setSelected(false);
		}
	}

	private Map<String, Object> getData(String strResult) {
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			JSONTokener jsonParser = new JSONTokener(strResult);
			JSONObject js = (JSONObject) jsonParser.nextValue();
			int code = Integer.parseInt(js.getString("Code"));
			if (code < 0) {
				// Toast.makeText(context, js.getString("Data"),
				// Toast.LENGTH_LONG).show();
				map = null;
			} else {
				map = ConvertJsonToList.getMap(js.getString("Data"));
				// Log.v("获取服务器数据getData", "map="+map.toString());
				// 无LotNumber时显示内容 SecState IsCanSee LotNumber=未上传
				if (map.get("SecState") != null) {
					if (!"公开".equals(map.get("SecState").toString())) {
						isSecret = true;
					}
				}
				if (map.get("LotNumber") != null) {
					if ("未上传".equals(map.get("LotNumber").toString())) {
						isNotUpload = true;
					} else {
						isNotUpload = false;
					}
				}
				if (map.get("IsShow") != null) {
					if ("false".equals(map.get("IsShow").toString())) {
						isToWeb = true;
					}
				}
				lottName = map.get("LottName").toString();
				// Log.d("getData", "LotName="+LotName.toString());
				isJcBasketball = false;
				isSFC = false;
				// layoutListPar.setBackgroundDrawable(null);
				// layoutListHeadPar.setVisibility(View.GONE);
				// layoutListHeadLine.setVisibility(View.GONE);
				try {
					
					System.out.println("111111111:"+lottName);
					if (lottName.indexOf("竞彩", 0) >= 0 || lottName.indexOf("足彩单场", 0) >= 0) {
						System.out.println("22222222222");
						if (lottName.indexOf("竞彩篮球", 0) >= 0) {
							isJcBasketball = true;
						} else if (lottName.indexOf("竞彩足球", 0) >= 0) {
							isJcFootball = true;
						} else if (lottName.indexOf("足彩单场", 0) >= 0) {
							isBd = true;
						}
						rData = getMatches(map);
						// Log.v("detail", "rData= "+rData.toString());
						isNumGame = false;
						if (!isNotUpload && !isToWeb) {
							layoutPassType.setVisibility(View.VISIBLE);
						}
					} else if ( lottName.contains("胜负彩") || lottName.contains("任选九") || lottName.indexOf("胜负彩", 0) >= 0 || lottName.indexOf("任选九", 0) >= 0) {
						System.out.println("33333333");
						isSFC = true;
						// layoutListPar.setBackgroundResource(R.drawable.set_info_head);
						// layoutListHeadPar.setVisibility(View.VISIBLE);
						// layoutListHeadLine.setVisibility(View.VISIBLE);
						rData = getSFCMatches(map);
						 Log.v("detail2", "rData= "+rData.toString());
						isNumGame = false;
						layoutPassType.setVisibility(View.GONE);
					} else {
						System.out.println("4444444");
						// 数字彩
						if (map.get("LotNumber") != null) {
							if (!"未上传".equals(map.get("LotNumber").toString())
									&& !"".equals(map.get("LotNumber").toString())) {
								Map<String, Object> lnmap = new HashMap<String, Object>();
								lnmap = ConvertJsonToList.getMap(map.get("LotNumber").toString());
								// 显示数字彩倍数
								if (lnmap.get("Multiple") != null) {
									tvMultiple.setText(lnmap.get("Multiple").toString());// 倍数
								}
								List<Map<String, Object>> lnlist = new ArrayList<Map<String, Object>>();
								if (lnmap.get("item") != null) {
									lnlist = ConvertJsonToList.getList(lnmap.get("item").toString());
								}
								// 名字 及 投注号
								if (lnlist != null) {
									for (int i = 0; i < lnlist.size(); i++) {
										Map<String, Object> nummap = new HashMap<String, Object>();
										nummap.put("PlayTypeName", lnlist.get(i).get("PlayTypeName"));
										// nummap.put("LotNum",
										// lnlist.get(i).get("LotNumber"));
										// nummap.put("LotNum",
										// lnlist.get(i).get("ColorNumber"));
										if (lnlist.get(i).containsKey("ColorNumber")) {
											nummap.put("LotNum", lnlist.get(i).get("ColorNumber"));
										} else {
											// Log.d("", "-------------");
											nummap.put("LotNum", lnlist.get(i).get("LotNumber"));
										}
										rData.add(nummap);
									}
								}
							}
						}
						isNumGame = true;
						layoutPassType.setVisibility(View.GONE);
					}
				} catch (Exception e) {
					// TODO: handle exception
					rData = null;
					isNumGame = true;
					layoutPassType.setVisibility(View.GONE);
				}
			}
		} catch (JSONException ex) {
			// 异常处理代码
			Log.e("error", ex.toString());
			map = null;
		}
		// Log.v("hemaidetail", "map= "+map.toString());
		// Log.v("hemaidetail", "rData= "+rData.toString());
		return map;
	}

	/**
	 * 方案信息
	 */
	public void setTextView() {
		String strLotName = mData.get("LottName").toString();

		String strIsYsq = getBundleStr("IsYsq");
		String strPeople = getBundleStr("UName");
		String Level = getBundleStr("Level");
		String strLaunchTime = mData.get("Issue").toString();
		String strStatus = mData.get("State").toString();
		String strAmount = mData.get("Money").toString().replace(".00", "");
		// 佣金比例
		String strCommission = mData.get("Bonus").toString() + "%";
		String strCanyu = mData.get("MC").toString();
		String strBaodi = mData.get("AM").toString() + "元";
		String strProcess1 = getBundleStr("Schedule");
		String strProcess2 = "(" + getBundleStr("Assure") + "%)";
		String strEndTime = mData.get("BuyEndTime").toString();
		if (!mData.get("MyWinMoney").toString().equals("") && (!mData.get("MyWinMoney").toString().equals("0.00"))
				&& (!mData.get("MyWinMoney").toString().equals("0.0"))
				&& (!mData.get("MyWinMoney").toString().equals("-"))
				&& (!mData.get("MyWinMoney").toString().equals("0"))) {
			isMyWinMoney = true;
		}
		// int intMoney = Integer.parseInt(String.valueOf(mData.get("Money")));
		float fMoney = Float.parseFloat(String.valueOf(mData.get("Money")).replaceAll(",", "").trim());
		// Log.d("detail", "fMoney= "+fMoney);
		int intBS = Integer.parseInt(String.valueOf(mData.get("BS")));
		// 可认购金额=方案金额-发起认购
		String strKRGMoney = String.valueOf((int) fMoney - intBS);
		// Log.d("detail", "strKRGMoney= "+strKRGMoney);
		tvKRGMoney.setText(strKRGMoney);
		tv_Lot.setText(strKRGMoney);
		if ("true".equals(strIsYsq)) {
			tvYsq.setVisibility(View.VISIBLE);
		} else if ("false".equals(strIsYsq)) {
			tvYsq.setVisibility(View.GONE);
		}

		// 需要加上不同战绩图片
		int intPicId = Integer.parseInt(Level);
		if (LevelUtil.getLevelIcon(intPicId) != 0) {
			ivLevel.setImageDrawable(context.getResources().getDrawable(LevelUtil.getLevelIcon(intPicId)));
		}

		lottImg.setImageResource(LotUtil.getLotIconIDByName(strLotName));
		// 减小显示空间
		if ("超级大乐透".equals(strLotName)) {
			strLotName = "大乐透";
		}
		// TODO
		if (mData.containsKey("Description")) {
			String descr = mData.get("Description").toString();
			if (!"".equals(descr)) {
				description_tex.setText(descr);
			}
		}
		if ("100".equals(strProcess1)) {
			llFoot.setVisibility(View.GONE);
		} else {
			llFoot.setVisibility(View.VISIBLE);
		}
		tvLotName.setText(strLotName);
		tvPeople.setText(strPeople);
		tvLaunchTime.setText(strLaunchTime);
		tvStatus.setText(strStatus);
		tvAmount.setText(strAmount);
		tvCommission.setText(strCommission);
		tvCanyu.setText(strCanyu);
		// tvBaodi.setText(strBaodi);
		DecimalFormat df = new DecimalFormat("00");
		String schedule = df.format(Double.parseDouble(strProcess1));
		tvProcess1.setText(schedule);
		tvProcess2.setText(strBaodi + " " + strProcess2);
		tvEndTime.setText(strEndTime);
		// tvMultiple.setText(mData.get("Multiple").toString());
		// LotNumber没有item时,及BetType =2,3,4,5,显示请至网站查看方案详情.默认显示未上传
		if (isToWeb) {
			hemai_detail_tvNO.setText("请至网站查看方案详情");
			tvSecState.setText("请至网站查看方案详情");
		}
		Boolean iscansee = (Boolean) mData.get("IsCanSee");
		if (!iscansee) {
			if (isSecret) {
				hemai_detail_tvNO.setText(mData.get("SecState").toString());
				tvSecState.setText(mData.get("SecState").toString());
			}
		}
		if (isNotUpload) {
			hemai_detail_tvNO.setText("未上传");
			tvSecState.setText("未上传");
		}
	}

	/**
	 * 购买
	 * 
	 * @param strResult
	 */
	public void HdetailBuy(String strResult) {
		try {
			JSONTokener jsonParser = new JSONTokener(strResult);
			JSONObject js = (JSONObject) jsonParser.nextValue();
			if (Integer.parseInt(js.getString("Code")) < 0) {
				buy_icon = R.drawable.buy_failure;
				// Log.i("Data= ", js.getString("Data"));
				// 余额不足
				if ("余额不足".equals(js.getString("Data"))) {
					new ShowTipDialog().showHBuyInfo(context, "您的当前余额不足，请先充值，再购买投注。", "购买失败", buy_icon);
				} else if ("方案已被用户撤单".equals(js.getString("Data"))) {
					new ShowTipDialog().showHBuyInfo(context, js.getString("Data"), "温馨提示", buy_icon);
				} else if (js.getString("Data").startsWith("方案剩余")) {
					// msg="方案剩余份数已不足 1893 份,剩余 1891 份";//新 元{ "Code": -1,
					// "Data": "方案剩余金额已不足2元,剩余1元"}
					String[] arr = js.getString("Data").split(",");
					String a = arr[1];
					String s = a.substring((a.indexOf("余") + 1), a.indexOf("元"));
					// fLeft = Integer.parseInt(s.trim());
					fLeft = Float.parseFloat(s.trim());
					ShowCustomDialog.Builder alertbBuilder = new ShowCustomDialog.Builder(context);
					alertbBuilder.setTitle("购买失败");
					// alertbBuilder.setMessage("可认购金额已不足" + fEnter +
					// "元，当前剩余金额为" + fLeft + "元，是否确定购买？");
					alertbBuilder.setMessage("该方案已满员");
					// alertbBuilder.setIcon(buy_icon);

					alertbBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int which) {
							// 以剩余金额继续购买
							fEnter = fLeft;
							// startHBuyThread();
							// Log.i("intEnter= ", intEnter + "");
							dialog.cancel();
						}
					}).createCustomDialog().show();
					;

					/*
					 * Dialog dialog = alertbBuilder.create();
					 * dialog.setCanceledOnTouchOutside(false);
					 * dialog.setCancelable(false);// 设置back键是否可以取消
					 * dialog.show();
					 */

				} else {
					new ShowTipDialog().showHBuyInfo(context, js.getString("Data"), "购买失败", buy_icon);
				}
			} else {
				buy_icon = R.drawable.buy_success;

				// String msg = "发起合买" + mData.get("Issue").toString() +
				// "期购买方案\n\n方案金额：" + mData.get("Money").toString() + "元\n我的认购："
				// + fEnter + "元";//\n账户余额：" + js.getString("Data") + "元
				String msg = "参与" + getBundleStr("UName") + "发起合买方案\n\n方案金额：" + mData.get("Money").toString()
						+ "元\n我的认购：" + fEnter + "元";
				// Log.d("msg= ", "购买 " + msg);
				new ShowTipDialog().showHBuyInfo(context, msg, js.getString("Data"), buy_icon);
			}
		} catch (JSONException e) {
			// 异常处理代码
			Log.e("error", e.toString());
		}
	}

	public boolean checkUserLogin() {
		// app = (ApplicationBall) ((Activity) context).getApplication();
		if (!ApplicationData.getInstance().getLoginName().equals("")
				&& !ApplicationData.getInstance().getLoginPwd().equals("")
				|| !ApplicationData.getInstance().getUserID().equals("")) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * 获取账户余额
	 * 
	 * @return
	 */
	public String getBalance() {
		String money = "";
		String strResult = null;
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			// 设置请求所需参数
			JSONObject params = new JSONObject();
			// 设置请求action
			String action = "107";// 108获取用户基本信息
			// 获取请求返回值
			String UserID = ApplicationData.getInstance().getUserID();
			strResult = GetRequestParams.getRequestUserIDResult(params.toString(), UserID, action,
					getApplicationContext());
			JSONTokener jsonParser = new JSONTokener(strResult);
			JSONObject js = (JSONObject) jsonParser.nextValue();
			map = ConvertJsonToList.getMap(js.getString("Data"));
			// money =
			// Float.parseFloat(map.get("Balance").toString().replaceAll(",",
			// "").trim());
			money = map.get("Balance").toString();
		} catch (Exception ex) {
			// TODO Auto-generated catch block
			Log.e("error", ex.toString());
		}
		return money;
	}

	private List<Map<String, Object>> getMatches(Map<String, Object> data) {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		Map<String, Object> numMap = new HashMap<String, Object>();
		if (data.get("LotNumber") != null) {
			if (!"未上传".equals(data.get("LotNumber").toString()) && !"".equals(data.get("LotNumber").toString())) {
				numMap = ConvertJsonToList.getMap(data.get("LotNumber").toString());
				if (numMap.get("PlayTypeName") != null) {
					if ("6".equals(data.get("BetType").toString())) {
						textPlayType.setText("一场决胜");// 玩法
						yhzx_detail_multiple_par.setVisibility(View.GONE);
					} else {
						textPlayType.setText(numMap.get("PlayTypeName").toString());// 玩法
					}

				}
				if (numMap.get("PassWay") != null) {
					if ("6".equals(data.get("BetType").toString())) {

						if (!AppUtils.isBlank(numMap.get("PassWay").toString())) {
							textPassType.setText(numMap.get("PassWay").toString());// 过关方式
						} else {
							textPassType.setText("2串1");
						}

					} else {
						textPassType.setText(numMap.get("PassWay").toString());// 过关方式
					}
				}
				if (numMap.get("Multiple") != null) {
					tvMultiple.setText(numMap.get("Multiple").toString());// 倍数
				}
				if (numMap.get("item") != null) {
					list = ConvertJsonToList.getList(numMap.get("item").toString());
				}
				PlayTypeName = numMap.get("PlayTypeName").toString();
				if (isJcBasketball) {
					if ("大小分".equals(PlayTypeName)) {
						isJcBasketballDXF = true;
					} else if ("胜负".equals(PlayTypeName)) {
						isJcBasketballSF = true;
					} else if ("让分胜负".equals(PlayTypeName)) {
						isJcBasketballRFSF = true;
					} else if ("胜分差".equals(PlayTypeName)) {
						isJcBasketballSFC = true;
					} else if ("混合过关".equals(PlayTypeName)) {
						isJcBasketballHunHe = true;
					}
				} else if (isJcFootball) {
					if ("让球胜平负".equals(PlayTypeName)) {
						isJczqRQSPF = true;
					} else if ("混合过关".equals(PlayTypeName)) {
						isJczqHunHe = true;
					} else if ("猜比分".equals(PlayTypeName)) {
						isJczqBF = true;
					} else if ("半全场".equals(PlayTypeName)) {
						isJczqBQC = true;
					} else if ("胜平负".equals(PlayTypeName)) {
						isJczqSPF = true;
					}
				} else if (isBd) {
					if ("半全场".equals(PlayTypeName)) {
						isBdBQC = true;
					} else if ("胜平负".equals(PlayTypeName)) {
						isBdSPF = true;
					} else if ("上下盘".equals(PlayTypeName) || "上下单双".equals(PlayTypeName)) {
						isBdSXDS = true;
					} else if ("猜比分".equals(PlayTypeName)) {
						isBdBF = true;
					}
				}
			}
		}
		return list;
	}

	private List<Map<String, Object>> getSFCMatches(Map<String, Object> data) {
		Map<String, Object> map = new HashMap<String, Object>();
		List<Map<String, Object>> newlist = new ArrayList<Map<String, Object>>();
		if (data.get("LotNumber") != null) {
			if (!"未上传".equals(data.get("LotNumber").toString()) && !"".equals(data.get("LotNumber").toString())) {
				map = ConvertJsonToList.getMap(data.get("LotNumber").toString());
				if (map.get("Multiple") != null) {
					tvMultiple.setText(map.get("Multiple").toString());// 倍数
				}
				List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
				if (map.get("item") != null) {
					list = ConvertJsonToList.getList(map.get("item").toString());
					// line {Result=0, VS=尼日利vs西班牙, OuOdds=10.40 5.25 1.26,
					// MTime=06-24 03:00, IsDan=false, Content=3, Score= <font
					// color=#a50000>0:3</font> , NO=1}
					// {content=0, od=3.42, oa=1.75, no=1, mtime=07-29 01:00,
					// score=2:0, cg=3, vs=耶夫勒(2:0)马尔默, oh=4.43}
					int length = list.size();
					System.out.println("length:"+length);
					for (int i = 0; i < length; i++) {
						Map<String, Object> oldmap = new HashMap<String, Object>();
						oldmap = list.get(i);
						Map<String, Object> newmap = new HashMap<String, Object>();
						// "NO", "Content", "HTeam", "VTeam", "Result", "Score"
						// ----sfc
						String HTeam = oldmap.get("vs").toString().split("vs")[0];
						String VTeam = oldmap.get("vs").toString().split("vs")[1];
						newmap.put("HTeam", HTeam);// 巴伊亚（2:1）戈亚斯
						newmap.put("VTeam", VTeam);
						newmap.put("Result", oldmap.get("cg"));
						newmap.put("Content", oldmap.get("content"));
						newmap.put("Score", oldmap.get("score"));
						newmap.put("NO", oldmap.get("no"));
						newlist.add(newmap);
					}
					System.out.println("newlist.size():"+newlist.size());
				}
			}
		}
		 Log.d("getSFCMatches", "合买详情newlist= "+newlist.toString());
		return newlist;
	}

	/**
	 * 处理竞彩篮球玩法网络数据，按listview字段分别适应加载到SimpleAdapter
	 */
	public List<Map<String, Object>> modifymjclqData(List<Map<String, Object>> list) {
		// "MNo", "Content", "HTeam", "VTeam", "Cg", "ysf", "Score","ysftv" 大小分
		// "MNo", "Content", "HTeam", "VTeam", "Cg", "Rq", "Score"
		// Log.v("list= ", list.toString());
		if (list != null && (!"".equals(list)) && list.size() != 0) {
			List<Map<String, Object>> NewList = new ArrayList<Map<String, Object>>();
			for (int i = 0; i < list.size(); i++) {
				Map<String, Object> OldMap = list.get(i);
				Map<String, Object> NewMap = new HashMap<String, Object>();
				if (isJcBasketballDXF) {
					NewMap.put("MNo", OldMap.get("no"));
					NewMap.put("Content", OldMap.get("content"));
					NewMap.put("HTeam", OldMap.get("hteam"));
					NewMap.put("VTeam", OldMap.get("vteam"));
					NewMap.put("Cg", OldMap.get("cg"));
					NewMap.put("ysf", OldMap.get("pre"));
					NewMap.put("Score", OldMap.get("score"));
					NewMap.put("ysftv", "预设分:");
				} else if (isJcBasketballSF || isJcBasketballSFC) {
					NewMap.put("MNo", OldMap.get("no"));
					NewMap.put("Content", OldMap.get("content"));
					NewMap.put("HTeam", OldMap.get("hteam"));
					NewMap.put("VTeam", OldMap.get("vteam"));
					NewMap.put("Cg", OldMap.get("cg"));
					NewMap.put("Rq", "");
					NewMap.put("Score", OldMap.get("score"));
				} else if (isJcBasketballRFSF) {
					NewMap.put("MNo", OldMap.get("no"));
					NewMap.put("Content", OldMap.get("content"));
					NewMap.put("HTeam", OldMap.get("hteam"));
					NewMap.put("VTeam", OldMap.get("vteam"));
					NewMap.put("Cg", OldMap.get("cg"));
					NewMap.put("Rq", OldMap.get("rf"));
					NewMap.put("Score", OldMap.get("score"));
					NewMap.put("vs", OldMap.get("vs"));
				} else if (isJcBasketballHunHe) {
					NewMap.put("MNo", OldMap.get("no"));
					NewMap.put("Content", OldMap.get("content"));
					NewMap.put("VTeam", OldMap.get("vteam"));
//					if (!"-".equals(OldMap.get("rf").toString()) && !"0".equals(OldMap.get("rf").toString())) {
//						NewMap.put("HTeam", OldMap.get("hteam").toString() + "(" + OldMap.get("rf").toString() + ")");
//					} else {
//						NewMap.put("HTeam", OldMap.get("hteam"));
//					}
					NewMap.put("HTeam", OldMap.get("hteam"));
					NewMap.put("VTeam", OldMap.get("vteam"));
					NewMap.put("vs", OldMap.get("vs"));
					NewMap.put("Rf", OldMap.get("rf"));
					NewMap.put("Score", OldMap.get("score"));
				} else {
					NewMap.put("MNo", OldMap.get("no"));
					NewMap.put("Content", OldMap.get("content"));
					NewMap.put("HTeam", OldMap.get("hteam"));
					NewMap.put("VTeam", OldMap.get("vteam"));
					NewMap.put("Cg", OldMap.get("cg"));
					// NewMap.put("Rq", OldMap.get("Rq"));
					NewMap.put("Score", OldMap.get("score"));
				}
				NewList.add(NewMap);
			}
			// Log.v("NewList= ", NewList.toString());
			return NewList;
		}
		return null;
	}

	/**
	 * 处理竞彩足球和足球单场(北单)玩法网络数据，按listview字段分别适应加载到SimpleAdapter
	 */
	public List<Map<String, Object>> modifymZQData(List<Map<String, Object>> list) {
		if (list != null && (!"".equals(list)) && list.size() != 0) {// "MNo",
																		// "Content",
																		// "HTeam",
																		// "VTeam",
																		// "Cg",
																		// "Rq",
																		// "Score"
			List<Map<String, Object>> NewList = new ArrayList<Map<String, Object>>();
			for (int i = 0; i < list.size(); i++) {
				if (lottName.indexOf("竞彩", 0) >= 0) {
					Map<String, Object> OldMap = list.get(i);
					Map<String, Object> NewMap = new HashMap<String, Object>();
					if (isJczqHunHe) {
						NewMap.put("MNo", OldMap.get("no"));
						NewMap.put("Content", OldMap.get("content"));
						// 如果是让球胜平负，主队后面加让球
						if (OldMap.get("content").toString().startsWith("让球")
								&& (!"-".equals(OldMap.get("rq").toString()))) {
							NewMap.put("HTeam", OldMap.get("hteam").toString() + "(" + OldMap.get("rq").toString()
									+ ")");
						} else {
							NewMap.put("HTeam", OldMap.get("hteam"));
						}
						NewMap.put("VTeam", OldMap.get("vteam"));
						NewMap.put("hScore", OldMap.get("hscore"));
						NewMap.put("Score", OldMap.get("score"));
						NewList.add(NewMap);
					} else if (isJczqRQSPF) {
						NewMap.put("MNo", OldMap.get("no"));
						NewMap.put("Content", OldMap.get("content"));
						// 如果是让球胜平负，主队后面加让球
						if (!"-".equals(OldMap.get("rq").toString()) && !"0".equals(OldMap.get("rq").toString())) {
							NewMap.put("HTeam", OldMap.get("hteam").toString() + "(" + OldMap.get("rq").toString()
									+ ")");
						} else {
							NewMap.put("HTeam", OldMap.get("hteam"));
						}
						NewMap.put("VTeam", OldMap.get("vteam"));
						// 处理赛果
						String strCG = "";
						strCG = OldMap.get("cg").toString();
						if (!strCG.equals("") && (!strCG.equals("-"))) {
							// 1转平
							strCG = strCG.replaceAll("3", "胜");
							strCG = strCG.replaceAll("1", "平");
							strCG = strCG.replaceAll("0", "负");
						}
						NewMap.put("Cg", strCG);
						NewMap.put("hScore", OldMap.get("hscore"));
						NewMap.put("Score", OldMap.get("score"));
						NewList.add(NewMap);
					} else if (isJczqSPF) {
						NewMap.put("MNo", OldMap.get("no"));
						NewMap.put("Content", OldMap.get("content"));
						NewMap.put("HTeam", OldMap.get("hteam"));
						NewMap.put("VTeam", OldMap.get("vteam"));
						// 处理赛果
						String strCG = "";
						strCG = OldMap.get("cg").toString();
						if (!strCG.equals("") && (!strCG.equals("-"))) {
							// 1转平
							strCG = strCG.replaceAll("3", "胜");
							strCG = strCG.replaceAll("1", "平");
							strCG = strCG.replaceAll("0", "负");
						}
						NewMap.put("Cg", strCG);
						NewMap.put("hScore", OldMap.get("hscore"));
						NewMap.put("Score", OldMap.get("score"));
						NewList.add(NewMap);
					} else if (isJczqBF) {
						NewMap.put("MNo", OldMap.get("no"));
						NewMap.put("Content", OldMap.get("content"));
						NewMap.put("HTeam", OldMap.get("hteam"));
						NewMap.put("VTeam", OldMap.get("vteam"));
						// 处理比分赛果
						String strCG = "";
						strCG = OldMap.get("cg").toString();
						if (!strCG.equals("") && (!strCG.equals("-"))) {
							// 22 转2:2
							strCG = strCG.substring(0, 1) + ":" + strCG.substring(1, strCG.length());
						}
						NewMap.put("Cg", strCG);
						NewMap.put("hScore", OldMap.get("hscore"));
						NewMap.put("Score", OldMap.get("score"));
						NewList.add(NewMap);
					} else if (isJczqBQC) {
						NewMap.put("MNo", OldMap.get("no"));
						NewMap.put("Content", OldMap.get("content"));
						NewMap.put("HTeam", OldMap.get("hteam"));
						NewMap.put("VTeam", OldMap.get("vteam"));
						// 处理赛果
						String strCG = "";
						strCG = OldMap.get("cg").toString();
						if (!strCG.equals("") && (!strCG.equals("-"))) {
							// 13转平胜
							strCG = strCG.replaceAll("3", "胜");
							strCG = strCG.replaceAll("1", "平");
							strCG = strCG.replaceAll("0", "负");
						}
						NewMap.put("Cg", strCG);
						NewMap.put("hScore", OldMap.get("hscore"));
						NewMap.put("Score", OldMap.get("score"));
						NewList.add(NewMap);
					} else {
						NewMap.put("MNo", OldMap.get("no"));
						NewMap.put("Content", OldMap.get("content"));
						NewMap.put("HTeam", OldMap.get("hteam"));
						NewMap.put("VTeam", OldMap.get("vteam"));
						NewMap.put("Cg", OldMap.get("cg"));
						NewMap.put("hScore", OldMap.get("hscore"));
						NewMap.put("Score", OldMap.get("score"));
						NewList.add(NewMap);
					}
				} else if (lottName.indexOf("足彩单场", 0) >= 0) {// 北京单场
					Map<String, Object> OldMap = list.get(i);
					Map<String, Object> NewMap = new HashMap<String, Object>();
					NewMap.put("MNo", OldMap.get("no"));
					NewMap.put("Content", OldMap.get("content"));
					if (OldMap.get("vs").toString().contains("VS")) {
						NewMap.put("HTeam", OldMap.get("vs").toString().split("VS")[0]);// "vs":
																						// "澳大利亚 VS 中　国"
						NewMap.put("VTeam", OldMap.get("vs").toString().split("VS")[1]);
						// NewMap.put("Rq", 0);
					} else {
						String rq = "";
						if (OldMap.get("vs").toString().split("\\(").length > 1) {
							rq = OldMap.get("vs").toString().split("\\(")[1].split("\\)")[0];
						}
						if ((!"".equals(rq)) && (!"-".equals(rq)) && (!"0".equals(rq))) {
							NewMap.put("HTeam", OldMap.get("vs").toString().split("\\(")[0] + "(" + rq + ")");
						} else {
							NewMap.put("HTeam", OldMap.get("vs").toString().split("\\(")[0]);
						}
						// "vs":// "卢恩吉亚(-1)下卡姆斯"
						String VTeam = OldMap.get("vs").toString().split("\\)")[1];
						if (VTeam.endsWith("胆")) {
							VTeam = VTeam + ")";
						}
						NewMap.put("VTeam", VTeam);
						// NewMap.put("Rq",
						// OldMap.get("vs").toString().split("\\(")[1].split("\\)")[0]);
					}
					// 处理赛果
					String strCG = "";
					strCG = OldMap.get("cg").toString();
					if (isBdBQC || isBdSPF) {
						if (!strCG.equals("") && (!strCG.equals("-"))) {
							// 3转胜
							strCG = strCG.replaceAll("3", "胜");
							strCG = strCG.replaceAll("1", "平");
							strCG = strCG.replaceAll("0", "负");
						}
					}
					if (isBdSXDS) {
						if (!strCG.equals("") && (!strCG.equals("-"))) {
							// 3上单，2上双，1下单，0下双
							strCG = strCG.replaceAll("3", "上单");
							strCG = strCG.replaceAll("2", "上双");
							strCG = strCG.replaceAll("1", "下单");
							strCG = strCG.replaceAll("0", "下双");
						}
					}
					if (isBdBF) {
						if (!strCG.equals("") && (!strCG.equals("-"))) {
							// 90胜其他，99平其他，09负其他
							strCG = strCG.replaceAll("90", "胜其他");
							strCG = strCG.replaceAll("99", "平其他");
							strCG = strCG.replaceAll("09", "负其他");
							if (strCG.length() == 2) {
								strCG = strCG.substring(0, 1) + ":" + strCG.substring(1, 2);
							}
						}
					}
					NewMap.put("Cg", strCG);
					NewMap.put("Score", OldMap.get("score"));
					NewList.add(NewMap);
				}
			}
			// Log.d("modifymJCZQData= ", "NewList= "+NewList.toString());
			return NewList;
		}
		return null;
	}

	/**
	 * 数字彩
	 * 
	 * @author Administrator
	 * 
	 */
	public class NumberPlanDetailAdapter extends SimpleAdapter {

		class ViewHolder {
			TextView tv_PlayTypeName;
			TextView tv_LotNum;
		}

		private LayoutInflater inflater = null;
		private int layoutId;
		private List<Map<String, Object>> data;

		public NumberPlanDetailAdapter(HeMaiDetailActivity context, List<Map<String, Object>> rData, int resource,
				String[] from, int[] to) {
			super(context, rData, resource, from, to);
			data = rData;
			inflater = LayoutInflater.from(HeMaiDetailActivity.this);
			layoutId = resource;
		}

		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			ViewHolder holder = null;
			holder = new ViewHolder();
			if (convertView == null) {
				convertView = inflater.inflate(layoutId, null);
				holder.tv_PlayTypeName = (TextView) convertView.findViewById(R.id.yhzx_plan_detail_PlayTypeName);
				holder.tv_LotNum = (TextView) convertView.findViewById(R.id.yhzx_plan_detail_winnum);
			} else {
				holder = (ViewHolder) convertView.getTag();
			}
			holder.tv_PlayTypeName.setText(Html.fromHtml(data.get(position).get("PlayTypeName").toString()));
			// holder.tv_LotNum.setText(Html.fromHtml(data.get(position).get("LotNum").toString()));
			// Log.v("plandetail", "data= "+data.toString());
			String ColorNumber = data.get(position).get("LotNum").toString().replaceAll("class", "color");
			// Log.v("plandetail", "LotNum= "+ColorNumber);
			ColorNumber = ColorNumber.replaceAll("\n", "<br>");
			holder.tv_LotNum.setText(Html.fromHtml(ColorNumber));
			convertView.setTag(holder);
			return convertView;
		}

	}

	public class SFCDetailAdapter extends SimpleAdapter {

		class ViewHolder {
			TextView tv_no;
			TextView tv_hteam;
			TextView tv_vteam;
			TextView tv_tz;
			TextView tv_score;
			TextView tv_cg;
		}

		private LayoutInflater inflater = null;
		private int layoutId;
		private List<Map<String, Object>> data;

		public SFCDetailAdapter(HeMaiDetailActivity context, List<Map<String, Object>> rData, int resource,
				String[] from, int[] to) {
			super(context, rData, resource, from, to);
			data = rData;
			inflater = LayoutInflater.from(HeMaiDetailActivity.this);
			layoutId = resource;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			ViewHolder holder = null;
			holder = new ViewHolder();
			if (convertView == null) {
				convertView = inflater.inflate(layoutId, null);
				holder.tv_no = (TextView) convertView.findViewById(R.id.yhzx_detail_list_mno);
				holder.tv_tz = (TextView) convertView.findViewById(R.id.yhzx_detail_list_tzh);
				holder.tv_hteam = (TextView) convertView.findViewById(R.id.yhzx_detail_list_hteam);
				holder.tv_vteam = (TextView) convertView.findViewById(R.id.yhzx_detail_list_vteam);
				holder.tv_cg = (TextView) convertView.findViewById(R.id.yhzx_detail_list_cg);
				holder.tv_score = (TextView) convertView.findViewById(R.id.yhzx_detail_list_score);

			} else {
				holder = (ViewHolder) convertView.getTag();
			}
			holder.tv_no.setText(data.get(position).get("NO").toString());
			holder.tv_tz.setText(Html.fromHtml(data.get(position).get("Content").toString()));
			holder.tv_hteam.setText(data.get(position).get("HTeam").toString());
			holder.tv_vteam.setText(data.get(position).get("VTeam").toString());
			holder.tv_cg.setText(data.get(position).get("Result").toString());
			holder.tv_score.setText(Html.fromHtml(data.get(position).get("Score").toString()));
			if (!data.get(position).get("Score").toString().equals("-")) {
				holder.tv_score.setTextColor(getResources().getColor(R.color.c_plandetails_sfc_red));
			}
			convertView.setTag(holder);
			return convertView;
		}

	}

	/**
	 * 竞彩足球混合过关
	 * 
	 * @author Administrator
	 * 
	 */
	public class jczqhhPlanDetailAdapter extends SimpleAdapter {

		class ViewHolder {
			TextView tv_no;
			TextView tv_hteam;
			TextView tv_vteam;
			TextView tv_tz;
			TextView tv_hscore;
			TextView tv_score;
		}

		private LayoutInflater inflater = null;
		private int layoutId;
		private List<Map<String, Object>> data;

		public jczqhhPlanDetailAdapter(Context context, List<Map<String, Object>> rData, int resource, String[] from,
				int[] to) {
			super(context, rData, resource, from, to);
			data = rData;
			inflater = LayoutInflater.from(HeMaiDetailActivity.this);
			layoutId = resource;
		}

		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			ViewHolder holder = null;
			holder = new ViewHolder();
			if (convertView == null) {
				convertView = inflater.inflate(layoutId, null);
				holder.tv_no = (TextView) convertView.findViewById(R.id.yhzx_detail_list_mno);
				holder.tv_tz = (TextView) convertView.findViewById(R.id.yhzx_detail_list_tzh);
				holder.tv_hteam = (TextView) convertView.findViewById(R.id.yhzx_detail_list_hteam);
				holder.tv_vteam = (TextView) convertView.findViewById(R.id.yhzx_detail_list_vteam);
				// holder.tv_hscore = (TextView)
				// convertView.findViewById(R.id.yhzx_detail_list_hscore);
				holder.tv_score = (TextView) convertView.findViewById(R.id.yhzx_detail_list_score);

			} else {
				holder = (ViewHolder) convertView.getTag();
			}
			holder.tv_no.setText(data.get(position).get("MNo").toString());
			holder.tv_tz.setText(Html.fromHtml(data.get(position).get("Content").toString()));

			String string = data.get(position).get("HTeam").toString();
			String newString = string.replace("()", "");
			holder.tv_hteam.setText(newString);
			holder.tv_vteam.setText(data.get(position).get("VTeam").toString());
			// holder.tv_hscore.setText(Html.fromHtml(data.get(position).get("hScore").toString()));
			if (isMyWinMoney) {
				holder.tv_hscore.setTextColor(getResources().getColor(R.color.c_plandetails_sfc_red));
				holder.tv_score.setTextColor(getResources().getColor(R.color.c_plandetails_sfc_red));
			}
			holder.tv_score.setText(Html.fromHtml(data.get(position).get("Score").toString()));

			convertView.setTag(holder);
			return convertView;
		}

	}

	/**
	 * 竞彩足球(混合过关除外),北京单场
	 * 
	 * @author Administrator
	 * 
	 */
	public class jczqPlanDetailAdapter extends SimpleAdapter {

		class ViewHolder {
			TextView tv_no;
			TextView tv_hteam;
			TextView tv_vteam;
			TextView tv_tz;
			TextView tv_cg;
			// TextView tv_rq;
			TextView tv_score;
		}

		private LayoutInflater inflater = null;
		private int layoutId;
		private List<Map<String, Object>> data;

		public jczqPlanDetailAdapter(Context context, List<Map<String, Object>> rData, int resource, String[] from,
				int[] to) {
			super(context, rData, resource, from, to);
			data = rData;
			inflater = LayoutInflater.from(context);
			layoutId = resource;
		}

		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			ViewHolder holder = null;
			holder = new ViewHolder();
			if (convertView == null) {
				convertView = inflater.inflate(layoutId, null);
				holder.tv_no = (TextView) convertView.findViewById(R.id.yhzx_detail_list_mno);
				holder.tv_tz = (TextView) convertView.findViewById(R.id.yhzx_detail_list_tzh);
				holder.tv_hteam = (TextView) convertView.findViewById(R.id.yhzx_detail_list_hteam);
				holder.tv_vteam = (TextView) convertView.findViewById(R.id.yhzx_detail_list_vteam);
				// holder.tv_rq = (TextView)
				// convertView.findViewById(R.id.yhzx_detail_list_rq);
				holder.tv_cg = (TextView) convertView.findViewById(R.id.yhzx_detail_list_cg);
				holder.tv_score = (TextView) convertView.findViewById(R.id.yhzx_detail_list_score);

			} else {
				holder = (ViewHolder) convertView.getTag();
			}
			holder.tv_no.setText(data.get(position).get("MNo").toString());
			holder.tv_tz.setText(Html.fromHtml(data.get(position).get("Content").toString()));
			holder.tv_hteam.setText(data.get(position).get("HTeam").toString());
			holder.tv_vteam.setText(data.get(position).get("VTeam").toString());
			// holder.tv_rq.setText(Html.fromHtml(data.get(position).get("Rq").toString()));
			holder.tv_cg.setText(data.get(position).get("Cg").toString());
			holder.tv_score.setText(Html.fromHtml(data.get(position).get("Score").toString()));

			convertView.setTag(holder);
			return convertView;
		}

	}

	/**
	 * 竞彩蓝球大小分
	 * 
	 * @author Administrator
	 * 
	 */
	public class jclqDXFPlanDetailAdapter extends SimpleAdapter {

		class ViewHolder {
			TextView tv_no;
			TextView tv_hteam;
			TextView tv_vteam;
			TextView tv_tz;
			TextView tv_cg;
			TextView tv_rq;
			TextView tv_score;
			TextView tv_ysf;
		}

		private LayoutInflater inflater = null;
		private int layoutId;
		private List<Map<String, Object>> data;

		public jclqDXFPlanDetailAdapter(Context context, List<Map<String, Object>> rData, int resource, String[] from,
				int[] to) {
			super(context, rData, resource, from, to);
			data = rData;
			inflater = LayoutInflater.from(context);
			layoutId = resource;
		}

		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			ViewHolder holder = null;
			holder = new ViewHolder();
			if (convertView == null) {
				convertView = inflater.inflate(layoutId, null);
				holder.tv_no = (TextView) convertView.findViewById(R.id.yhzx_detail_list_mno);
				holder.tv_tz = (TextView) convertView.findViewById(R.id.yhzx_detail_list_tzh);
				holder.tv_hteam = (TextView) convertView.findViewById(R.id.yhzx_detail_list_hteam);
				holder.tv_vteam = (TextView) convertView.findViewById(R.id.yhzx_detail_list_vteam);
				holder.tv_cg = (TextView) convertView.findViewById(R.id.yhzx_detail_list_cg);
				holder.tv_rq = (TextView) convertView.findViewById(R.id.yhzx_detail_list_rq);// 预设分
				holder.tv_score = (TextView) convertView.findViewById(R.id.yhzx_detail_list_score);// 比分
				holder.tv_ysf = (TextView) convertView.findViewById(R.id.yhzx_detail_list_tvysf);// 让分

			} else {
				holder = (ViewHolder) convertView.getTag();
			}
			holder.tv_no.setText(data.get(position).get("MNo").toString());
			holder.tv_tz.setText(Html.fromHtml(data.get(position).get("Content").toString()));
			holder.tv_hteam.setText(data.get(position).get("HTeam").toString());
			holder.tv_vteam.setText(data.get(position).get("VTeam").toString());
			holder.tv_cg.setText(data.get(position).get("Cg").toString());
			holder.tv_rq.setVisibility(View.VISIBLE);
			holder.tv_rq.setText(Html.fromHtml(data.get(position).get("ysf").toString()));
			holder.tv_score.setText(Html.fromHtml(data.get(position).get("Score").toString()));
			holder.tv_ysf.setVisibility(View.GONE);
			holder.tv_ysf.setText(Html.fromHtml(data.get(position).get("ysf").toString()));

			convertView.setTag(holder);
			return convertView;
		}

	}

	/**
	 * 竞彩蓝球让分胜负
	 * 
	 * @author Administrator
	 * 
	 */
	public class jclqRFSFPlanDetailAdapter extends SimpleAdapter {

		class ViewHolder {
			TextView tv_no;
			TextView tv_hteam;
			TextView tv_vteam;
			TextView tv_tz;
			TextView tv_cg;
//			TextView tv_rq;
			TextView tv_score;
//			TextView tv_ysf;
		}

		private LayoutInflater inflater = null;
		private int layoutId;
		private List<Map<String, Object>> data;

		public jclqRFSFPlanDetailAdapter(Context context, List<Map<String, Object>> rData, int resource, String[] from,
				int[] to) {
			super(context, rData, resource, from, to);
			data = rData;
			inflater = LayoutInflater.from(context);
			layoutId = resource;
		}

		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			ViewHolder holder = null;
			holder = new ViewHolder();
			if (convertView == null) {
				convertView = inflater.inflate(layoutId, null);
				holder.tv_no = (TextView) convertView.findViewById(R.id.yhzx_detail_list_mno);
				holder.tv_tz = (TextView) convertView.findViewById(R.id.yhzx_detail_list_tzh);
				holder.tv_hteam = (TextView) convertView.findViewById(R.id.yhzx_detail_list_hteam);
				holder.tv_vteam = (TextView) convertView.findViewById(R.id.yhzx_detail_list_vteam);
				holder.tv_cg = (TextView) convertView.findViewById(R.id.yhzx_detail_list_cg);
//				holder.tv_rq = (TextView) convertView.findViewById(R.id.yhzx_detail_list_rq);// 预设分
				holder.tv_score = (TextView) convertView.findViewById(R.id.yhzx_detail_list_score);// 比分
//				holder.tv_ysf = (TextView) convertView.findViewById(R.id.yhzx_detail_list_tvysf);// 让分

			} else {
				holder = (ViewHolder) convertView.getTag();
			}
			holder.tv_no.setText(data.get(position).get("MNo").toString());
			holder.tv_tz.setText(Html.fromHtml(data.get(position).get("Content").toString()));
			holder.tv_vteam.setText(data.get(position).get("vs").toString());
//			holder.tv_hteam.setText(data.get(position).get("HTeam").toString());
//			holder.tv_vteam.setText(data.get(position).get("VTeam").toString());
			holder.tv_cg.setText(data.get(position).get("Cg").toString());
//			holder.tv_rq.setText(Html.fromHtml(data.get(position).get("Rq").toString()));
			holder.tv_score.setText(Html.fromHtml(data.get(position).get("Score").toString()));
//			holder.tv_ysf.setText(Html.fromHtml(data.get(position).get("Rq").toString()));
			convertView.setTag(holder);
			return convertView;
		}

	}

	/**
	 * 竞彩蓝球(除大小分，让分胜负,混合投注)
	 * 
	 * @author Administrator
	 * 
	 */
	public class jclqPlanDetailAdapter extends SimpleAdapter {

		class ViewHolder {
			TextView tv_no;
			TextView tv_hteam;
			TextView tv_vteam;
			TextView tv_tz;
			TextView tv_cg;
			TextView tv_score;
		}

		private LayoutInflater inflater = null;
		private int layoutId;
		private List<Map<String, Object>> data;

		public jclqPlanDetailAdapter(Context context, List<Map<String, Object>> rData, int resource, String[] from,
				int[] to) {
			super(context, rData, resource, from, to);
			data = rData;
			inflater = LayoutInflater.from(context);
			layoutId = resource;
		}

		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			ViewHolder holder = null;
			holder = new ViewHolder();
			if (convertView == null) {
				convertView = inflater.inflate(layoutId, null);
				holder.tv_no = (TextView) convertView.findViewById(R.id.yhzx_detail_list_mno);
				holder.tv_tz = (TextView) convertView.findViewById(R.id.yhzx_detail_list_tzh);
				holder.tv_hteam = (TextView) convertView.findViewById(R.id.yhzx_detail_list_hteam);
				holder.tv_vteam = (TextView) convertView.findViewById(R.id.yhzx_detail_list_vteam);
				holder.tv_cg = (TextView) convertView.findViewById(R.id.yhzx_detail_list_cg);
				holder.tv_score = (TextView) convertView.findViewById(R.id.yhzx_detail_list_score);

			} else {
				holder = (ViewHolder) convertView.getTag();
			}
			holder.tv_no.setText(data.get(position).get("MNo").toString());
			holder.tv_tz.setText(Html.fromHtml(data.get(position).get("Content").toString()));
			holder.tv_hteam.setText(data.get(position).get("HTeam").toString());
			holder.tv_vteam.setText(data.get(position).get("VTeam").toString());
			holder.tv_cg.setText(data.get(position).get("Cg").toString());
			holder.tv_score.setText(Html.fromHtml(data.get(position).get("Score").toString()));

			convertView.setTag(holder);
			return convertView;
		}

	}

	/**
	 * 竞彩蓝球混合投注
	 * 
	 * @author Administrator
	 * 
	 */
	public class jclqHunHePlanDetailAdapter extends SimpleAdapter {

		class ViewHolder {
			TextView tv_no;
			TextView tv_hteam;
			TextView tv_vteam;
			TextView tv_tz;
			TextView tv_rf;
			TextView tv_score;
		}

		private LayoutInflater inflater = null;
		private int layoutId;
		private List<Map<String, Object>> data;

		public jclqHunHePlanDetailAdapter(Context context, List<Map<String, Object>> rData, int resource,
				String[] from, int[] to) {
			super(context, rData, resource, from, to);
			data = rData;
			inflater = LayoutInflater.from(HeMaiDetailActivity.this);
			layoutId = resource;
		}

		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			ViewHolder holder = null;
			holder = new ViewHolder();
			if (convertView == null) {
				convertView = inflater.inflate(layoutId, null);
				holder.tv_no = (TextView) convertView.findViewById(R.id.yhzx_detail_list_mno);
				holder.tv_tz = (TextView) convertView.findViewById(R.id.yhzx_detail_list_tzh);
				holder.tv_hteam = (TextView) convertView.findViewById(R.id.yhzx_detail_list_hteam);
				holder.tv_vteam = (TextView) convertView.findViewById(R.id.yhzx_detail_list_vteam);
				holder.tv_rf = (TextView) convertView.findViewById(R.id.yhzx_detail_list_rf);
				holder.tv_score = (TextView) convertView.findViewById(R.id.yhzx_detail_list_score);

			} else {
				holder = (ViewHolder) convertView.getTag();
			}
			holder.tv_no.setText(data.get(position).get("MNo").toString());
			holder.tv_tz.setText(Html.fromHtml(data.get(position).get("Content").toString()));
			holder.tv_hteam.setText(data.get(position).get("HTeam").toString());
			holder.tv_vteam.setText(data.get(position).get("VTeam").toString());
//			holder.tv_rf.setText(Html.fromHtml(data.get(position).get("Rf").toString()));
			holder.tv_score.setText(Html.fromHtml(data.get(position).get("Score").toString()));

			convertView.setTag(holder);
			return convertView;
		}

	}

	/**
	 * 标题栏
	 */
	public void titleBar() {
		// Title信息(返回+Title)
		TextView back = (TextView) findViewById(R.id.top_title_back);
		// back.getBackground().setAlpha(255);// 透明度0~255透明度值 ，值越小越透明
		// back.setVisibility(View.INVISIBLE);
		back.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});

		// TextView info = (TextView) findViewById(R.id.top_title_info);
		// info.setText(R.string.buy);

		// 复制方案链接
		TextView refres = (TextView) findViewById(R.id.top_title_right);
		// refres.getBackground().setAlpha(155);// 透明度0~255透明度值 ，值越小越透明
		refres.setVisibility(View.VISIBLE);
		refres.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				String shareUrl = Constants.SHARE_URL_TEST + schemeID;
				String shareTitle = Constants.PLANDET_SHARE_HEMAI;
				startActivity(Intent.createChooser(
						new Intent(Intent.ACTION_SEND).setType("text/plain")
								.putExtra(Intent.EXTRA_TEXT, shareTitle + shareUrl)
								.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK), ""));

				/*
				 * startActivity(Intent .createChooser( new
				 * Intent(Intent.ACTION_SEND) .setType("text/plain")
				 * .putExtra(Intent.EXTRA_TEXT,
				 * getString(R.string.share_content))
				 * .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
				 * getString(R.string.share_title)));
				 */

			}
		});
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			HeMaiDetailActivity.this.finish();
			return true;
		} else {
			return super.onKeyDown(keyCode, event);
		}

	};

	@Override
	public void finish() {
		// TODO Auto-generated method stub
		super.finish();
		SysApplication.getInstance().removeActivity(this);
	};

	public void refreshActity() {

		// handler.postDelayed(new Runnable() {
		//
		// @Override
		// public void run() {
		// // TODO Auto-generated method stub
		// startDetailThread();
		// }
		// }, 1000);

	}

	Handler handler = new Handler();
}
